package com.fangcun.service.admin.Impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fangcun.bean.admin.teahouse.response.TeahouseSearchResponse;
import com.fangcun.bean.sys.PageBean;
import com.fangcun.common.canstant.ErrCode;
import com.fangcun.common.exception.ProException;
import com.fangcun.common.exception.ProValiDataException;
import com.fangcun.entity.Teahouse;
import com.fangcun.mapper.TeahouseMapper;
import com.fangcun.service.admin.TeahouseService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Service
public class TeahouseServiceImpl implements TeahouseService{
	
	@Autowired
	private TeahouseMapper teahouseMapper;

	@Override
	public PageInfo<TeahouseSearchResponse> list(PageBean<Teahouse> request) throws ProException {
		PageHelper.startPage(request.getPageNum(), request.getPageSize());
		List<TeahouseSearchResponse> list = teahouseMapper.selectAll(request.getParam());
		if (list == null || list.size() == 0) {
			throw new ProValiDataException(ErrCode.NO_DATA.getReturnCode(), ErrCode.NO_DATA.getReturnMsg());
		}
		return new PageInfo<>(list);
	}
	
	
}
